/* ---------------------------------------------------------------------------------------------
 *
 *            Capital Alliance Software Confidential Proprietary
 *            (c) Copyright CAS 201{x}, All Rights Reserved
 *                          www.pekall.com
 *
 * ----------------------------------------------------------------------------------------------
 */

package com.pekall.myDictionary.screens;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.pekall.myDictionary.utils.ShareUtil;

public class CopyRightScreen extends Activity implements OnClickListener {

    private Button mRightOK;

    private Button mRightCancle;

    private ShareUtil mShareUtil;

    private ImageView mIsChecked;

    private boolean isChecked;

    /*
     * (non-Javadoc)
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        String model = Build.MODEL;
        if ("t8301".equalsIgnoreCase(model) || "t8100".equalsIgnoreCase(model)) {
            Intent intent = new Intent();
            intent.setClass(this, HomeScreen.class);
            startActivity(intent);
            this.finish();
        }
        
        mShareUtil = new ShareUtil(this);
        if (mShareUtil.getString("pronouncement").equals("1")) {
            Intent intent = new Intent();
            intent.setClass(this, HomeScreen.class);
            startActivity(intent);
            this.finish();
        }
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.copyright);
        mRightOK = (Button) findViewById(R.id.right_ok);
        mRightCancle = (Button) findViewById(R.id.right_cancle);
        mIsChecked = (ImageView) findViewById(R.id.ischecked);
        mRightOK.setOnClickListener(this);
        mRightCancle.setOnClickListener(this);
        mIsChecked.setOnClickListener(this);

    }

    public void onClick(View v) {
        if (v.getId() == R.id.right_ok) {
            Intent intent = new Intent();
            intent.setClass(this, HomeScreen.class);
            startActivity(intent);
            if (isChecked)
                mShareUtil.ok();
            this.finish();
        } else if (v.getId() == R.id.right_cancle) {
            finish();
        }
        if (v.getId() == R.id.ischecked) {
            ImageView iv = (ImageView) v;
            if (!isChecked) {
                iv.setBackgroundResource(R.drawable.btn_check_on);
                isChecked = true;
            } else {
                iv.setBackgroundResource(R.drawable.btn_check_off);
                isChecked = false;
            }

        }
    }

}
